//
//  CheckItemViewModel.m
//  MobileChecker
//
//  Created by Lymons on 15-1-5.
//  Copyright (c) 2015年 Lymons. All rights reserved.
//

#import "CheckItemViewModel.h"
#import "CheckResultUserDefaults.h"
#import "AppDelegate.h"
#import "Steps.h"

@interface CheckItemViewModel ()

@end

@implementation CheckItemViewModel

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.itemsResult = [[NSMutableArray alloc] init];
    }
    return self;
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.items.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.tableViewCellIdentifier forIndexPath:indexPath];
    cell.textLabel.text = nil;
    cell.detailTextLabel.text = @" "; // detailLabel's frame be changed to zero if set nil
    NSString *item = [self.items objectAtIndex:indexPath.row];
    if ([item isEqualToString:ITEM_RESULT_NONE]) {
        return cell;
    }
    cell.textLabel.text = item;
    NSString *result = [self.itemsResult objectAtIndex:indexPath.row];
    if ([result isEqualToString:ITEM_RESULT_NONE] == NO) {
        cell.detailTextLabel.text = result;
    }
    cell.detailTextLabel.textColor = [CheckResultUserDefaults valueColor:result];
    
    return cell;
}

@end
